package com.lekang.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lekang.common.annotation.Log;
import com.lekang.common.core.controller.BaseController;
import com.lekang.common.core.domain.AjaxResult;
import com.lekang.common.enums.BusinessType;
import com.lekang.system.domain.WxUserBinding;
import com.lekang.system.service.IWxUserBindingService;
import com.lekang.common.utils.poi.ExcelUtil;
import com.lekang.common.core.page.TableDataInfo;

/**
 * 客户信息表Controller
 * 
 * @author zhihao
 * @date 2025-10-16
 */
@RestController
@RequestMapping("/system/wx-binding")
public class WxUserBindingController extends BaseController
{
    @Autowired
    private IWxUserBindingService wxUserBindingService;

    /**
     * 查询客户信息表列表
     */
    @PreAuthorize("@ss.hasPermi('system:binding:list')")
    @GetMapping("/list")
    public TableDataInfo list(WxUserBinding wxUserBinding)
    {
        startPage();
        List<WxUserBinding> list = wxUserBindingService.selectWxUserBindingList(wxUserBinding);
        return getDataTable(list);
    }

    /** 
     * 导出客户信息表列表
     */
    @PreAuthorize("@ss.hasPermi('system:binding:export')")
    @Log(title = "客户信息表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WxUserBinding wxUserBinding)
    {
        List<WxUserBinding> list = wxUserBindingService.selectWxUserBindingList(wxUserBinding);
        ExcelUtil<WxUserBinding> util = new ExcelUtil<WxUserBinding>(WxUserBinding.class);
        util.exportExcel(response, list, "客户信息表数据");
    }

    /**
     * 获取客户信息表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:binding:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wxUserBindingService.selectWxUserBindingById(id));
    }

    /**
     * 新增客户信息表
     */
    @PreAuthorize("@ss.hasPermi('system:binding:add')")
    @Log(title = "客户信息表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WxUserBinding wxUserBinding)
    {
        return toAjax(wxUserBindingService.insertWxUserBinding(wxUserBinding));
    }

    /**
     * 修改客户信息表
     */
    @PreAuthorize("@ss.hasPermi('system:binding:edit')")
    @Log(title = "客户信息表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WxUserBinding wxUserBinding)
    {
        return toAjax(wxUserBindingService.updateWxUserBinding(wxUserBinding));
    }

    /**
     * 删除客户信息表
     */
    @PreAuthorize("@ss.hasPermi('system:binding:remove')")
    @Log(title = "客户信息表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wxUserBindingService.deleteWxUserBindingByIds(ids));
    }
}
